From de47b90fd10ac494fda16af4c723ed2d5f6be946 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 16 Nov 2011 18:47:39 +0000 Subject: [PATCH] gtk: Parse keypad numbers correctly Try to find keycodes for keysyms at level-0 in the keymap, but don't fail to parse if we can find those in level-1. This fixes the parsing of numerical keys on the keypad, which require a shift level through Num-Lock. https://bugzilla.gnome.org/show_bug.cgi?id=606727 --- gtk/gtkaccelgroup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c index 6d30880cda..18b40b6a95 100644 --- a/gtk/gtkaccelgroup.c +++ b/gtk/gtkaccelgroup.c @@ -1380,12 +1380,20 @@ gtk_accelerator_parse_with_keycode (const gchar *accelerator, { *accelerator_codes = g_new0 (guint, n_keys + 1); + /* Prefer level-0 keys to modified keys */ for (i = 0, j = 0; i < n_keys; ++i) { if (keys[i].level == 0) (*accelerator_codes)[j++] = keys[i].keycode; } + /* No level-0 keys? Find in the whole keymap */ + if (j == 0) + { + for (i = 0, j = 0; i < n_keys; ++i) + (*accelerator_codes)[j++] = keys[i].keycode; + } + if (j == 0) { g_free (*accelerator_codes); -- 2.30.2